<style>
.layui-icon-close{color:red;font-weight: bold;}
.layui-icon-ok{color:#5FB878;font-weight: bold;}
</style>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	
	<!-- END RIBBON -->
	<div class="content">
		<div class="panel panel-default panel-intro">
			<div class="panel-heading">
				<div class="panel-lead">
					<em>CMS - 栏目列表</em>
                    注意：如果您未选择项目，请先前往【项目管理】模块，创建或选中一个项目为当前模型绑定对象。
				</div>
			</div>
			<div class="panel-body">
				<div id="myTabContent" class="tab-content">
					<div class="tab-pane fade active in" id="one">
						<div class="widget-body no-padding">
							<div class="bootstrap-table">
								
								<div class="fixed-table-toolbar">
									<div class="bs-bars pull-left">
										<div id="toolbar" class="toolbar">
											<a href="javascript:window.location.reload();" class="btn btn-primary btn-refresh" title="刷新">
												<i class="fa fa-refresh"></i>
											</a>
											{if condition="$adminController->vif('model','add')"}
											<a href="javascript:add('{:url('add')}');" class="btn btn-success btn-add" title="添加"><i class="fa fa-plus"></i> 添加</a>
											{/if}
										</div>
									</div>
									<div class="columns columns-right btn-group pull-right">
										<div class="keep-open btn-group" title="列">
											<button type="button" aria-label="columns" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
												<i class="glyphicon glyphicon-th icon-th"></i>
												<span class="caret"></span>
											</button>
												<ul class="dropdown-menu" id="table_menu">
												
											</ul>
										</div>
									</div>
								</div>
								<div class="fixed-table-container" style="padding-bottom: 0px;">
									<div class="fixed-table-body">
										<table id="table" class="table table-striped table-bordered table-hover" width="100%">
											<thead>
												<tr>
													<th data-status="1" width=""><div class="th-inner" style="text-align: left;">栏目名称</div></th>
													<th data-status="1" width=""><div class="th-inner">链接地址</div></th>
													<th data-status="1" width="200"><div class="th-inner">Icon</div></th>
													<th data-status="1" width="120"><div class="th-inner">默认高亮</div></th>
													<th data-status="1" width="120"><div class="th-inner">操作</div></th>
												</tr>
											</thead>
											
											<tbody id="content-main">

												{foreach name="list" item="v"}
												<tr class="del-{$v.ic_id}">
													<td align="left">{$v.ic_title}</td>
													<td align="center">
														<a href="{$v.ic_href}" target="_blank">{$v.ic_href}</a>
													</td>
													<td align="center">{$v.ic_icon}</td>
													<td align="center">
														{if condition="$v.ic_high == 1"}
															<i class="layui-icon layui-icon-ok">&#xe605;</i>
														{else /}
															<i class="layui-icon layui-icon-close">&#x1006;</i>
														{/if}
													</td>
													<td style="text-align: center; vertical-align: middle; ">
														{if condition="$adminController->vif('column','upd')"}
														<a href="javascript:upd('{:url('upd', ['id'=>$v['ic_id']])}');" class="btn btn-xs btn-success btn-editone" title="编辑">
															<i class="fa fa-pencil"></i>
														</a>
														{/if}
														{if condition="$adminController->vif('column','delete')"}
														<button data-id="{$v.ic_id}" onclick="return del(this)" class="btn btn-xs btn-danger btn-delone del_menu" title="删除">
															<i class="fa fa-trash"></i>
														</button>
														{/if}
													</td>
												</tr>
												{/foreach}
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>


<script>
{if condition="!$item"}
$.thinkmimi({Content : '请先前往项目管理模块，选中一个项目！', Type:2, Align:'right', OutTime:4000});	
{/if}
layui.use(['form'], function(){
  var form = layui.form;
});
// 删除
function del(_this) {
	var id = $(_this).attr('data-id');
	$.ajax({
		type: 'post',
		data: {'id':id},
		url: '{:url("delete")}',
		success: function(data) {
			var array = eval('('+data+')');
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		}
	});
}
// 添加
function add(href) {
	layer.open({
		type: 2,
		title: '添加新栏目',
		shadeClose: true,
		shade: false,
		maxmin: true,
		area: ['750px', '600px'],
		btn: ['确认', '取消'],
		content: href,
		yes: function(index, layero) {
			var _this = layero.find('iframe')[0];
			var bool  = _this.contentWindow.doSubimt();
			if (bool !== false) {
				$.thinkmimi({Content : bool['msg'],Type : 1,Align:'right',OutTime:2000,});
				menu_run();
				layer.closeAll();
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		},
	});
}
// 修改
function upd(href) {
	layer.open({
		type: 2,
		title: '修改栏目',
		shadeClose: true,
		shade: false,
		maxmin: true,
		area: ['750px', '600px'],
		btn: ['确认', '取消'],
		content: href,
		yes: function(index, layero) {
			var _this = layero.find('iframe')[0];
			var bool  = _this.contentWindow.doSubimt();
			if (bool !== false) {
				$.thinkmimi({Content : bool['msg'],Type : 1,Align:'right',OutTime:2000,});
				menu_run();
				layer.closeAll();
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		},
	});
}
</script>
